<?php
/**
 * Created by PhpStorm.
 * User: micoy
 * Date: 2018/12/15
 * Time: 0:50
 */

namespace app\admin\controller;


use think\Controller;
use think\Db;

/**
 *
 * Class SettingController
 * @package app\admin\controller
 */
class SettingController extends AuthController {

    public function GetSetting() {

        $key = input('key');

        $setting = Db::table('setting')->where('map_key', $key)->find();
        if (!$setting) {
            return Success("", "");
        }

        return Success("", $setting['map_value']);

    }

    public function SetSetting() {
        $key = input('key');
        $value = input('value');

        $setting = Db::table('setting')->where('map_key', $key)->find();
        if (!$setting) {
            Db::table('setting')->insert([
                'map_key'   =>  $key,
                'map_value' =>  $value,
            ]);
        }

        Db::table('setting')->where('map_key', $key)->update([
            'map_value' =>  $value,
        ]);

        return Success("", $value);
    }

}